﻿using System;
using System.Collections.Generic;
using System.Text;
using ESCommon.Rtf;
using ESCommon;
using System.Drawing;

namespace NCS_CS
{
    public class ReportRtfc
    {
        private RtfDocument rtf;
        
        public ReportRtfc()
        {
            rtf = new RtfDocument();
            rtf.FontTable.Add(new RtfFont("Calibri"));
            rtf.FontTable.Add(new RtfFont("Constantia"));
            rtf.ColorTable.AddRange(new RtfColor[] {
                new RtfColor(Color.Red),
                new RtfColor(0, 0, 255)
            });

            RtfParagraphFormatting LeftAligned12 = new RtfParagraphFormatting(12, RtfTextAlign.Left);
            RtfParagraphFormatting Centered10 = new RtfParagraphFormatting(10, RtfTextAlign.Center);

            RtfFormattedParagraph header = new RtfFormattedParagraph(new RtfParagraphFormatting(16, RtfTextAlign.Center));
            //RtfFormattedParagraph p1 = new RtfFormattedParagraph(new RtfParagraphFormatting(12, RtfTextAlign.Left));
            header.AppendText("氧氮分析结果");
            int rows = ModMain.gfrmMain.samples.Count;
            RtfTable t = new RtfTable(RtfTableAlign.Center,3, rows+1);
            t.DefaultCellStyle = new RtfTableCellStyle(RtfBorderSetting.None, Centered10);
            int i = 0;
            t[0, i].AppendText("样品名称");
            t[1, i].AppendText("C%");
            t[2, i].AppendText("S%");
            i++;
            foreach (NCS.sample s in ModMain.gfrmMain.samples)
            {
                t[0, i].AppendText(s.name);
                t[1, i].AppendText(s.c.ToString());
                t[2, i].AppendText(s.s.ToString());
                i++;
            }
            rtf.Contents.AddRange(new RtfDocumentContentBase[] {
                header,
                t
            });
        }

        public RtfDocument GetRtf()
        {
            return rtf;
        }
    }
}